//
//  QWFUpdateCheck.m
//  AFNetworking
//
//  Created by ice on 2019/3/5.
//

#import "QWFUpdateCheck.h"
#import "QFWSdkNetManager.h"



@implementation QWFUpdateCheck


- (instancetype)init {
    
    if (self = [super init]) {
        
    }
    
    return self;
}


- (NSMutableDictionary *)requestParams {
    NSMutableDictionary *params = [NSMutableDictionary dictionary];

    params[@"service"] = @"update_check";
    params[@"version"] = @1;
    params[@"model"] = _modelName;

    
    NSMutableDictionary *appDict = [NSMutableDictionary dictionary];
    appDict[@"package_name"] = _packageName;
    appDict[@"version_code"] = _versionCode;
    appDict[@"version_name"] = _versionName;
    
    params[@"app"] = appDict;

    NSMutableDictionary *firmwareDict = [NSMutableDictionary dictionary];
    firmwareDict[@"version_code"] = _firmwareVersionCode;
    firmwareDict[@"version_name"] = _firmwareVersionName;
    
    params[@"firmware"] = firmwareDict;


    
    return params;
}

- (void)deviceCheckUpdate {
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    
    params = [self requestParams];
    
    NSString *url = @"http://114.115.215.79:8099/ars/us/update/service";
//    url = @"http://www.baidu.com/";
//    url = @"http://ip.taobao.com/service/getIpInfo.php?ip=63.223.108.42";
//    url = @"https://www.qiushibaike.com/text/";
    
    [QFWSdkNetManager POST:url
                parameters:params
                  response:^(NSURLSessionDataTask *task, id responseObject, NSError *error) {
        
                      NSLog(@"===responseObject %@  error %@===", responseObject, error);
    }];
}

@end
